Repository navigation
fix(route): Intl 真实模型直连透传(桌面端同步)——修复 gpt-*/gemini-* 被内置系列通配改写 - #234
Merged
Merged
Conversation
与服务端 smart-open#232 同一 bug、同一补丁,本 PR 是 `src-tauri/src/api_server/` 下的对应移植。 buddy-ai 国际档开启时,Intl 目录内的真实模型会被 ③ 内置系列通配改写成 CN 目录目标: - `gpt-6.2-sol` → `deepseek-v4-pro`,buddy-ai 池无此模型 → 上游 400/11102 - `gemini-3.8-flash` → `glm-5.3`,静默换模型(响应 model 与请求不一致) 根因:`resolve()` 只判「③ 命中 + **目标**在目录中」,没有「请求名本身是否已在目录 中」的判定;调用侧传的是 CN 目录(无 `gpt-*`),`deepseek-v4-pro` 恰好在 CN 目录 里,改写被判为合法。随后 `cn_hit=true` 使 `buddy_intl_only` 恒为 false,请求带着 改写后的 CN 模型名进了 buddy-ai 池。 修复:新增 `resolve_with_intl(cfg, catalog, intl, requested)`,在 **①别名 ②用户 自定义规则之后、③内置系列通配之前** 插入 ⓪ 直连命中。`resolve()` 降为 `intl = None` 的薄包装,CN-only 部署零行为变化。 ⓪ 不能放在 ①② 之前:那样 `glm-5.3-thinking`、`claude-sonnet-4.5` 这类靠后缀/ 系列改写才能工作的请求会被原样透传成不存在的模型。 调用侧:`dispatch::resolve_target` 里 `buddy_ai_enabled` 与 `intl_catalog` 的读取 前移到 `resolve` 之前(本文件原本在 resolve 之后读,与服务端分支不同); `routes::resolve_wb_target` 同上。 新增 4 个单测,与服务端 smart-open#232 完全同源。
smart-open
pushed a commit
that referenced
this pull request
Nov 30, 2026
- #213 P3:伪流式开关/重试预算/keep-alive 改持久化(服务未运行也可改,启动即装载); 新增首字降级阈值(默认 10s,0=关闭):流式首字超时改投聚合内核,不冷却账号; 传输掐断日志附 [cut_kind=… sent=…] 分类后缀 - #231:UID 融合迁移账号 OAuth 登录修复——回调旧 uid 与 JWT 新 uid 经服务端 GetUserInfo(GetUIDFusionInfo) 权威校验放行,防篡改边界保留;GetUserInfo 改 x-cloudide-token 头 + 补请求体,库内旧 uid 账号原位改名合并 - 首字失败分类 FirstByteFail(Timeout=窗口耗尽/Dead=首行前 IO/EOF)五池收口: TTFT 降级只认 Timeout,Dead 保持账号冷却语义(审查修复:IO 故障不得混入降级通道); Custom 池首字失败报错按形态区分 - 503 归因键候选升级 resolve_with_intl 对齐 PR #234 直连口径(审查修复) - CodeArts 耗尽 tried_accounts 补齐 identity 失败与排队重发失败分支(审查修复) - 升版 3.9.7(sync_version 全 5 处 + package-lock 两处根字段)+ README 版本徽标 与 CodeArts 文档补全 - 验证基线:cargo test 1454/0/21 + cargo check 零警告 + tsc 零错误 + vitest 103 全过
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
buddy_ai_enabled = true且 Intl 目录已同步时,Intl 目录内的真实模型会被 ③ 内置系列通配改写(与 #233 同一个 bug,这里是桌面端):modelgpt-6.2-sol/gpt-6.2-astra/gpt-6.1-sol/gpt-6-sol/gpt-5.6-*deepseek-v4-pro{"code":11102,"msg":"model [deepseek-v4-pro] service info not found"}(buddy-ai 池无此模型)gemini-3.8-flashglm-5.3model是glm-5.3—— 静默换模型,计量与对比全部失真根因
resolve()的判定是「③ 系列通配命中 + 目标在目录中 → 采纳」,没有「请求名本身是否已在目录中」的判定。而调用侧(dispatch::resolve_target)传进去的是 CN 目录(不含gpt-*),deepseek-v4-pro/glm-5.3恰好都在 CN 目录里,于是改写被判为合法。改写之后
cn_hit = wb_catalog::find(&catalog, &r.model).is_some()因为拿到的是 CN 模型名而恒为true,buddy_intl_only随之恒为false,请求带着改写后的 CN 模型名进了 buddy-ai 池 → 上游 11102。改动
src-tauri/src/api_server/wb_model_route.rs:新增resolve_with_intl(cfg, catalog, intl, requested),在 ①别名 ②用户自定义规则之后、③内置系列通配之前 插入 ⓪ 直连命中 —— 请求名已在 CN 或 Intl 目录中即原样透传(stage = "direct")。resolve()降为intl = None的薄包装。dispatch.rs:buddy_ai_enabled的读取前移到resolve之前,intl_catalog也提到resolve之前加载,然后走resolve_with_intl。routes.rs::resolve_wb_target:同上(/v1/responses入口)。⓪ 不能放在 ①② 之前:那样
glm-5.3-thinking、claude-sonnet-4.5这类靠后缀 / 系列改写才能工作的请求会被原样透传成不存在的模型,等于废掉另外两级。放在 ② 与 ③ 之间既修掉劫持,又保留用户别名 / 规则的覆盖能力。intl = None(国际档关闭、CN-only 部署)时保持原四段语义,零行为变化。与服务端分支的关系
同一补丁已提到
docker_main:#232。两个目录下的wb_model_route.rs结构一致,本 PR 是逐行对应的移植(差异只在dispatch.rs—— 服务端那边buddy_ai_enabled本来就在resolve之前读,这边原本在之后)。验证情况(请注意边界)
intl=None保持原语义 / 别名与规则仍可覆盖直连 / 目录外名字仍走系列通配与后缀 —— 与服务端 fix(route): Intl 真实模型直连透传——修复 gpt-*/gemini-* 被内置系列通配改写 #232 里的 4 个测试逐行同源。cargo test --bin ai-work-assistant --no-run有 47 个错误,全部落在windows_sys/Command::creation_flags/lnk/windows_registry等 Windows 专属模块,api_server/目录零错误(说明本次改动本身类型正确,但完整编译与测试仍需 Windows 环境)。crates/aiwork-core)上已实跑:cargo test -p aiwork-core --lib→ 1012 passed, 0 failed,并在 NanoPi R2S(aarch64)实机验证过行为:gpt-6.2-solmodel=deepseek-v4-pro→ 400/11102gemini-3.8-flashmodel=glm-5.3glm-5.3-thinking/claude-sonnet-4.5/gpt-4o本 PR 未包含
builtin_series()里("o1*"/"o3*"/"o4*", "hy4")的目标hy4同样已经失效 —— 上游把 id 改成了hy4std(display仍是"Hy4"),目录被同步覆盖后裸hy4不复存在,该级永远命中不了,o3-mini被原样透传、上游回4001 param is invalid。修法涉及「用哪个型号替代 OpenAI 推理模型」的产品判断,没有一并改。建议另外补一个启动期断言:builtin_series()的每个 target 若在 CN 与 Intl 目录里都找不到就 warn 一次。同源 issue:#233 服务端 PR:#232